package com.mindskip.xzs.repository;

import com.mindskip.xzs.domain.Question;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Component
public class QuestionTestRepository {

    private QuestionMapper mapper;

    @Autowired
    public QuestionTestRepository(QuestionMapper mapper) {
        this.mapper = mapper;

    }

    public Question selectRandom(Set<Integer> excludeIds) {
        List<Question> questions = selectRandom(1, excludeIds);
        if (null == questions || questions.size() == 0) {
            return null;
        }
        return questions.get(0);
    }

    public List<Question> selectRandom(int number, Set<Integer> excludeIds) {
        return mapper.selectRandom(number, excludeIds);
    }

    public List<Question> selectRandom(int number, List<Integer> excludeIds) {
        return mapper.selectRandom(number, excludeIds);

    }
}
